﻿#region Usings

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.Surface.Presentation.Controls;
using ScrumTable.BL.DM.DataManagement;
using ScrumTable.UI.View.Controls;
using ScrumTable.UI.View.Extension;
using ScrumTable.UI.ViewModel;

#endregion

namespace ScrumTable.UI.View.WinTouch.CustomControl
{
    /// <summary>
    /// DropControl. Use this class for showing a dropping control
    /// </summary>
    public class DropControl : UserControl, IDropUserControl
    {

        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        /// <summary>
        /// DependencyProperty for IsScrollVisible.
        /// </summary>
        public static readonly DependencyProperty CanDropPredicateProperty =
            DependencyProperty.Register("CanDropPredicate",
                                        typeof(Predicate<object>),
                                        typeof(DropControl),
                                        new UIPropertyMetadata(null));

        public Predicate<object> CanDropPredicate
        {
            get { return (Predicate<object>)GetValue(CanDropPredicateProperty); }
            set { SetValue(CanDropPredicateProperty, value); }
        }
 
        /// <summary>
        /// DependencyProperty for IsScrollVisible.
        /// </summary>
        public static readonly DependencyProperty DropTypeProperty =
            DependencyProperty.Register("DropType",
                                        typeof(Type),
                                        typeof(DropControl),
                                        new UIPropertyMetadata(null));
        /// <summary>
        /// Gets or sets if the ScrollViewer is currently visible.
        /// </summary>
        /// <value>If the ScrollViewer is visible.</value>
        public Type DropType
        {
            get { return (Type)GetValue(DropTypeProperty); }
            set { SetValue(DropTypeProperty, value); }
        }
        #endregion
        
        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------
     
        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        public DropControl()
        {
            DropType = typeof(UserStoryViewModel);
        }
        #endregion




        #region Methods
   
      
        #endregion


        #region Events

        #region IDropUserControl Members

        public FrameworkElement GetRootControl
        {
            get { return this; }
        }

        public bool ShowIconWithbackground
        {
            get { return false; }
        }

        public CanDropResult CanDrop(object objectToDrop)
        {
            if (CanDropPredicate == null)
            {
                return this.ConvertBoolToEnum(objectToDrop.GetType() == DropType);
            }
            return this.ConvertBoolToEnum(CanDropPredicate(objectToDrop));
        }

        #endregion

        #endregion
    }
}
